﻿Public Class main

    Public Shared PROVIDERPOLICIES As New PROVIDERSCLASS

    Private Sub ButtonItem29_Click(sender As Object, e As EventArgs) Handles ButtonItem29.Click
        countryMaster.Execute()
    End Sub

    Private Sub countryMaster_Executed(sender As Object, e As EventArgs) Handles countryMaster.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is MASCOUNTRY Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next

        If PROVIDERPOLICIES.GETCHECKVIEWPRG(Convert.ToString(MASCOUNTRY.Tag)) = True Then
            Dim doc As New MASCOUNTRY()
            doc.Text = "MASCOUNTRY"
            doc.MdiParent = Me
            doc.WindowState = FormWindowState.Maximized
            doc.Show()
            doc.Update()
        Else
            MsgBox(PROVIDERPOLICIES.PSEEMSG_)
        End If
        
    End Sub

    'maschangwat
    Private Sub ButtonItem30_Click(sender As Object, e As EventArgs) Handles ButtonItem30.Click
        provinceMaster.Execute()
    End Sub

    Private Sub provinceMaster_Executed(sender As Object, e As EventArgs) Handles provinceMaster.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is MASPROVINCE Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New MASPROVINCE()
        doc.Text = "MASPROVINCE"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'masampur
    Private Sub ButtonItem31_Click(sender As Object, e As EventArgs) Handles ButtonItem31.Click
        districtMaster.Execute()
    End Sub

    Private Sub districtMaster_Executed(sender As Object, e As EventArgs) Handles districtMaster.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is MASDISTRICT Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New MASDISTRICT()
        doc.Text = "MASDISTRICT"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'mastambon
    Private Sub ButtonItem32_Click(sender As Object, e As EventArgs) Handles ButtonItem32.Click
        subdistrictMaster.Execute()
    End Sub

    Private Sub subdistrictMaster_Executed(sender As Object, e As EventArgs) Handles subdistrictMaster.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is MASSUBDISTRICT Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New MASSUBDISTRICT()
        doc.Text = "MASSUBDISTRICT"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'ประเภทที่อยู่
    Private Sub ButtonItem125_Click(sender As Object, e As EventArgs) Handles ButtonItem125.Click
        addressType.Execute()
    End Sub

    Private Sub addressType_Executed(sender As Object, e As EventArgs) Handles addressType.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is ADDRESSTYPE Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New ADDRESSTYPE()
        doc.Text = "ADDRESSTYPE"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'ประเภทบ้าน
    Private Sub ButtonItem126_Click(sender As Object, e As EventArgs) Handles ButtonItem126.Click
        houseType.Execute()
    End Sub

    Private Sub houseType_Executed_1(sender As Object, e As EventArgs) Handles houseType.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is HOUSETYPE Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New HOUSETYPE()
        doc.Text = "HOUSETYPE"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'คำนำหน้า
    Private Sub ButtonItem104_Click(sender As Object, e As EventArgs) Handles ButtonItem104.Click
        preName.Execute()
    End Sub

    Private Sub preName_Executed(sender As Object, e As EventArgs) Handles preName.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is PRENAME Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New PRENAME()
        doc.Text = "PRENAME"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'SEX
    Private Sub ButtonItem35_Click(sender As Object, e As EventArgs) Handles ButtonItem35.Click
        SEX.Execute()
    End Sub

    Private Sub SEX_Executed(sender As Object, e As EventArgs) Handles SEX.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is SEX Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New SEX()
        doc.Text = "SEX"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'กรุ๊ปเลือด
    Private Sub ButtonItem37_Click(sender As Object, e As EventArgs) Handles ButtonItem37.Click
        ABGroup.Execute()
    End Sub

    Private Sub ABGroup_Executed(sender As Object, e As EventArgs) Handles ABGroup.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is ABGROUP Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New ABGROUP()
        doc.Text = "ABGroup"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'RhGroup
    Private Sub ButtonItem38_Click(sender As Object, e As EventArgs) Handles ButtonItem38.Click
        RhGroup.Execute()
    End Sub

    Private Sub RhGroup_Executed(sender As Object, e As EventArgs) Handles RhGroup.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is RHGROUP Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New RHGROUP()
        doc.Text = "RHGROUP"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'สัญชาติ
    Private Sub ButtonItem39_Click(sender As Object, e As EventArgs) Handles ButtonItem39.Click
        nation.Execute()
    End Sub

    Private Sub NATION_Executed(sender As Object, e As EventArgs) Handles nation.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is NATION Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New NATION()
        doc.Text = "NATION"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'ศาสนา
    Private Sub ButtonItem42_Click(sender As Object, e As EventArgs) Handles ButtonItem42.Click
        Religion.Execute()
    End Sub

    Private Sub Religion_Executed(sender As Object, e As EventArgs) Handles Religion.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is RELIGION Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New RELIGION()
        doc.Text = "RELIGION"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'อาชีพ
    Private Sub ButtonItem45_Click(sender As Object, e As EventArgs) Handles ButtonItem45.Click
        Occupation.Execute()
    End Sub

    Private Sub Occupation_Executed(sender As Object, e As EventArgs) Handles Occupation.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is OCCUPATION Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New OCCUPATION()
        doc.Text = "OCCUPATION"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'สถานภาพสมรส
    Private Sub ButtonItem43_Click(sender As Object, e As EventArgs) Handles ButtonItem43.Click
        maritalStatus.Execute()
    End Sub

    Private Sub maritalStatus_Executed(sender As Object, e As EventArgs) Handles maritalStatus.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is MARITALSTATUS Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New MARITALSTATUS()
        doc.Text = "MARITALSTATUS"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'education
    Private Sub ButtonItem44_Click(sender As Object, e As EventArgs) Handles ButtonItem44.Click
        Education.Execute()
    End Sub

    Private Sub Education_Executed(sender As Object, e As EventArgs) Handles Education.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is EDUCATION Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New EDUCATION()
        doc.Text = "EDUCATION"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'กลุ่มลูกค้า
    Private Sub ButtonItem46_Click(sender As Object, e As EventArgs) Handles ButtonItem46.Click
        VStatus.Execute()
    End Sub

    Private Sub VStatus_Executed(sender As Object, e As EventArgs) Handles VStatus.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is VSTATUS Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New VSTATUS()
        doc.Text = "VSTATUS"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'อารมณ์ผู้ป่วย
    Private Sub Feeling_Executed(sender As Object, e As EventArgs) Handles Feeling.Executed
        Feeling.Execute()
    End Sub

    Private Sub ButtonItem105_Click(sender As Object, e As EventArgs) Handles ButtonItem105.Click
        For Each f As Form In Application.OpenForms
            If TypeOf f Is FEELING Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New FEELING()
        doc.Text = "FEELING"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'ประเภทผู้ป่วย
    Private Sub ButtonItem47_Click(sender As Object, e As EventArgs) Handles ButtonItem47.Click
        patientType.Execute()
    End Sub

    Private Sub patientType_Executed(sender As Object, e As EventArgs) Handles patientType.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is PATIENTTYPE Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New PATIENTTYPE()
        doc.Text = "PATIENTTYPE"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'ข้อความแจ้งเตือน
    Private Sub ButtonItem48_Click(sender As Object, e As EventArgs) Handles ButtonItem48.Click
        notifyMessage.Execute()
    End Sub

    Private Sub notifyMessage_Executed(sender As Object, e As EventArgs) Handles notifyMessage.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is NOTIFYMESSAGE Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New NOTIFYMESSAGE()
        doc.Text = "NOTIFYMESSAGE"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'นามแฝง
    Private Sub ButtonItem41_Click(sender As Object, e As EventArgs) Handles ButtonItem41.Click
        penName.Execute()
    End Sub

    Private Sub penName_Executed(sender As Object, e As EventArgs) Handles penName.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is PENNAME Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New PENNAME()
        doc.Text = "PENNAME"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'การจำหน่าย
    Private Sub ButtonItem49_Click(sender As Object, e As EventArgs) Handles ButtonItem49.Click
        discharge.Execute()
    End Sub

    Private Sub discharge_Executed(sender As Object, e As EventArgs) Handles discharge.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DISCHARGE Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DISCHARGE()
        doc.Text = "DISCHARGE"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'ที่เก็บแฟ้ม
    Private Sub ButtonItem50_Click(sender As Object, e As EventArgs) Handles ButtonItem50.Click
        locationFile.Execute()
    End Sub

    Private Sub locationFile_Executed(sender As Object, e As EventArgs) Handles locationFile.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is LOCATIONF Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New LOCATIONF()
        doc.Text = "LOCATIONF"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'maspstatus สถานะผู้ป่วย
    Private Sub btnMaspstatus_Click(sender As Object, e As EventArgs) Handles btnMaspstatus.Click
        maspstatus.Execute()
    End Sub

    Private Sub maspstatus_Executed(sender As Object, e As EventArgs) Handles maspstatus.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is MASPSTATUS Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New MASPSTATUS()
        doc.Text = "MASPSTATUS"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    '---------------------hospital data-------------------------

    'hospital data and network
    Private Sub ButtonItem40_Click(sender As Object, e As EventArgs) Handles ButtonItem40.Click
        hospitalDataAndNetwork.Execute()
    End Sub

    Private Sub hospitalDataAndNetwork_Executed(sender As Object, e As EventArgs) Handles hospitalDataAndNetwork.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is HOSPITAL Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New HOSPITAL()
        doc.Text = "HOSPITAL"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'สถานที่จัดเก็บ
    Private Sub ButtonItem51_Click(sender As Object, e As EventArgs) Handles ButtonItem51.Click
        documentKeepPlace.Execute()
    End Sub

    Private Sub documentKeepPlace_Executed(sender As Object, e As EventArgs) Handles documentKeepPlace.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is KEEPPLACE Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New KEEPPLACE()
        doc.Text = "KEEPPLACE"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'clinic
    Private Sub ButtonItem52_Click(sender As Object, e As EventArgs) Handles ButtonItem52.Click
        clinic.Execute()
    End Sub

    Private Sub clinic_Executed(sender As Object, e As EventArgs) Handles clinic.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is CLINIC Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New CLINIC()
        doc.Text = "CLINIC"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'บุคลากรทางการแพทย์
    Private Sub ButtonItem53_Click(sender As Object, e As EventArgs) Handles ButtonItem53.Click
        provider.Execute()
    End Sub

    Private Sub provider_Executed(sender As Object, e As EventArgs) Handles provider.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is PROVIDER Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New PROVIDER()
        doc.Text = "PROVIDER"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'Vital sign
    Private Sub ButtonItem33_Click(sender As Object, e As EventArgs) Handles ButtonItem33.Click
        vsType.Execute()
    End Sub

    Private Sub vsType_Executed(sender As Object, e As EventArgs) Handles vsType.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is VSTYPE Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New VSTYPE()
        doc.Text = "VSTYPE"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'ตารางออกตรวจ
    Private Sub ButtonItem54_Click(sender As Object, e As EventArgs) Handles ButtonItem54.Click
        DrTime.Execute()
    End Sub

    Private Sub DrTime_Executed(sender As Object, e As EventArgs) Handles DrTime.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRTIME Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRTIME()
        doc.Text = "DRTIME"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'รหัสโรค ICD
    Private Sub ButtonItem127_Click(sender As Object, e As EventArgs) Handles ButtonItem127.Click
        ICD.Execute()
    End Sub

    Private Sub ICD_Executed(sender As Object, e As EventArgs) Handles ICD.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DIAG Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DIAG()
        doc.Text = "DIAG"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'mtRGT
    Private Sub ButtonItem102_Click(sender As Object, e As EventArgs) Handles ButtonItem102.Click
        mtRGT.Execute()
    End Sub

    Private Sub mtRgt_Executed(sender As Object, e As EventArgs) Handles mtRGT.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is MTRGT Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New MTRGT()
        doc.Text = "MTRGT"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'stRGT
    Private Sub ButtonItem103_Click(sender As Object, e As EventArgs) Handles ButtonItem103.Click
        stRGT.Execute()
    End Sub

    Private Sub stRGT_Executed(sender As Object, e As EventArgs) Handles stRGT.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is STRGT Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New STRGT()
        doc.Text = "STRGT"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'sbRGT
    Private Sub ButtonItem106_Click(sender As Object, e As EventArgs) Handles ButtonItem106.Click
        sbRGT.Execute()
    End Sub

    Private Sub sbRGT_Executed(sender As Object, e As EventArgs) Handles sbRGT.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is SBRGT Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New SBRGT()
        doc.Text = "SBRGT"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'typeRGT
    Private Sub ButtonItem142_Click(sender As Object, e As EventArgs) Handles ButtonItem142.Click
        typeRGT.Execute()
    End Sub

    Private Sub typeRGT_Executed(sender As Object, e As EventArgs) Handles typeRGT.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is TYPERGT Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New TYPERGT()
        doc.Text = "TYPERGT"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    '------------------ Product And Service----------------------

    'รายการยา
    Private Sub ButtonItem56_Click(sender As Object, e As EventArgs) Handles ButtonItem56.Click
        DrugItem.Execute()
    End Sub

    Private Sub DrugItem_Executed(sender As Object, e As EventArgs) Handles DrugItem.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRUGITEM Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRUGITEM()
        doc.Text = "DRUGITEM"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'vaccine
    Private Sub ButtonItem115_Click(sender As Object, e As EventArgs) Handles ButtonItem115.Click
        vaccine.Execute()
    End Sub

    Private Sub vaccine_Executed(sender As Object, e As EventArgs) Handles vaccine.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is VACCINE Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New VACCINE()
        doc.Text = "VACCINE"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'กลุ่มยา
    Private Sub ButtonItem58_Click(sender As Object, e As EventArgs) Handles ButtonItem58.Click
        drugGroup.Execute()
    End Sub

    Private Sub drugGroup_Executed(sender As Object, e As EventArgs) Handles drugGroup.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRUGGROUP Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRUGGROUP()
        doc.Text = "DRUGGROUP"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'ประเภทยา
    Private Sub ButtonItem59_Click(sender As Object, e As EventArgs) Handles ButtonItem59.Click
        drugType.Execute()
    End Sub

    Private Sub drugType_Executed(sender As Object, e As EventArgs) Handles drugType.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRUGTYPE Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRUGTYPE()
        doc.Text = "DRUGTYPE"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'บัญชียา
    Private Sub ButtonItem60_Click(sender As Object, e As EventArgs) Handles ButtonItem60.Click
        drugAccount.Execute()
    End Sub

    Private Sub drugAccount_Executed(sender As Object, e As EventArgs) Handles drugAccount.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRUGACCOUNT Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRUGACCOUNT()
        doc.Text = "DRUGACCOUNT"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'รูปแบบยา
    Private Sub ButtonItem62_Click(sender As Object, e As EventArgs) Handles ButtonItem62.Click
        drugDosage.Execute()
    End Sub

    Private Sub drugDosage_Executed(sender As Object, e As EventArgs) Handles drugDosage.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRUGDOSAGE Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRUGDOSAGE()
        doc.Text = "DRUGDOSAGE"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'ความเข้มข้น
    Private Sub ButtonItem63_Click(sender As Object, e As EventArgs) Handles ButtonItem63.Click
        drugInten.Execute()
    End Sub

    Private Sub drugInten_Executed(sender As Object, e As EventArgs) Handles drugInten.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRUGINTEN Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRUGINTEN()
        doc.Text = "DRUGINTEN"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'ประเภทและรหัสการออกฤทธิ์
    Private Sub ButtonItem12_Click_2(sender As Object, e As EventArgs) Handles ButtonItem12.Click
        drugAtcCode.Execute()
    End Sub

    Private Sub drugAtcCode_Executed(sender As Object, e As EventArgs) Handles drugAtcCode.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRUGATCCODE Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRUGATCCODE()
        doc.Text = "DRUGATCCODE"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'ความต่อเนื่องในการออกฤทธิ์
    Private Sub drgDiSetBtn_Click(sender As Object, e As EventArgs) Handles drgDiSetBtn.Click
        drgDiSet.Execute()
    End Sub

    Private Sub drgDiSet_Executed(sender As Object, e As EventArgs) Handles drgDiSet.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRGDISET Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRGDISET()
        doc.Text = "DRGDISET"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'เวลาการใช้ยา
    Private Sub ButtonItem67_Click(sender As Object, e As EventArgs) Handles ButtonItem67.Click
        drugTime.Execute()
    End Sub

    Private Sub drugTime_Executed(sender As Object, e As EventArgs) Handles drugTime.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRUGTIME Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRUGTIME()
        doc.Text = "DRUGTIME"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'วิธีใช้ยา
    Private Sub ButtonItem65_Click(sender As Object, e As EventArgs) Handles ButtonItem65.Click
        drugUse.Execute()
    End Sub

    Private Sub drugUse_Executed(sender As Object, e As EventArgs) Handles drugUse.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRUGUSE Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRUGUSE()
        doc.Text = "DRUGUSE"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'วิธีใช้ยา 2
    Private Sub drugUse2_Click(sender As Object, e As EventArgs) Handles drugUse2.Click
        drugUseVer2.Execute()
    End Sub

    Private Sub drugUseVer2_Executed(sender As Object, e As EventArgs) Handles drugUseVer2.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRUGUSE2 Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRUGUSE2()
        doc.Text = "DRUGUSE2"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'ฉลากเตือน
    Private Sub btnMasslabel_Click(sender As Object, e As EventArgs) Handles btnMasslabel.Click
        drugMasslabel.Execute()
    End Sub

    Private Sub drugMasslabel_Executed(sender As Object, e As EventArgs) Handles drugMasslabel.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRUGCAUTION Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRUGCAUTION()
        doc.Text = "DRUGCAUTION"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'วิธีการเก็บ
    Private Sub ButtonItem66_Click(sender As Object, e As EventArgs) Handles ButtonItem66.Click
        drugKeep.Execute()
    End Sub

    Private Sub drugKeep_Executed(sender As Object, e As EventArgs) Handles drugKeep.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRUGKEEP Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRUGKEEP()
        doc.Text = "DRUGKEEP"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    Private Sub drgugBtn_Click(sender As Object, e As EventArgs) Handles drgugBtn.Click
        drgug.Execute()
    End Sub

    Private Sub drgug_Executed(sender As Object, e As EventArgs) Handles drgug.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRGUG Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRGUG()
        doc.Text = "DRGUG"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'DrugdoseWuse
    Private Sub ButtonItem79_Click(sender As Object, e As EventArgs) Handles ButtonItem79.Click
        drugDoseUse.Execute()
    End Sub

    Private Sub drugDoseUse_Executed(sender As Object, e As EventArgs) Handles drugDoseUse.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRUGDOSEWUSE Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRUGDOSEWUSE()
        doc.Text = "DRUGDOSEWUSE"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'DrugitemWuse
    Private Sub ButtonItem80_Click(sender As Object, e As EventArgs) Handles ButtonItem80.Click
        drugItemUse.Execute()
    End Sub

    Private Sub drugItemUse_Executed(sender As Object, e As EventArgs) Handles drugItemUse.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRUGITEMWUSE Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRUGITEMWUSE()
        doc.Text = "DRUGITEMWUSE"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'ผูกวิธีการใช้ยากับตัวยา
    Private Sub ButtonItem13_Click_2(sender As Object, e As EventArgs) Handles ButtonItem13.Click
        drugItemWithUse.Execute()
    End Sub

    Private Sub drugItemWithUse_Executed(sender As Object, e As EventArgs) Handles drugItemWithUse.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRUGUSETEMPLATE Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRUGUSETEMPLATE()
        doc.Text = "DRUGUSETEMPLATE"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'ที่เก็บยา
    Private Sub ButtonItem75_Click(sender As Object, e As EventArgs) Handles ButtonItem75.Click
        drugLocation.Execute()
    End Sub

    Private Sub drugLocation_Executed(sender As Object, e As EventArgs) Handles drugLocation.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRUGLOCATION Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRUGLOCATION()
        doc.Text = "DRUGLOCATION"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'ผู้ผลิตยา
    Private Sub ButtonItem76_Click(sender As Object, e As EventArgs) Handles ButtonItem76.Click
        drugMaker.Execute()
    End Sub

    Private Sub drugMaker_Executed(sender As Object, e As EventArgs) Handles drugMaker.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRUGMAKER Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRUGMAKER()
        doc.Text = "DRUGMAKER"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'ผู้ค้ายา
    Private Sub ButtonItem14_Click_2(sender As Object, e As EventArgs) Handles ButtonItem14.Click
        drugAgent.Execute()
    End Sub

    Private Sub drugAgent_Executed(sender As Object, e As EventArgs) Handles drugAgent.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRUGAGENT Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRUGAGENT()
        doc.Text = "DRUGAGENT"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'agentCVF
    Private Sub ButtonItem15_Click_2(sender As Object, e As EventArgs) Handles ButtonItem15.Click
        agentCVF.Execute()
    End Sub

    Private Sub agentCVF_Executed(sender As Object, e As EventArgs) Handles agentCVF.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRUGAGENTCVF Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRUGAGENTCVF()
        doc.Text = "DRUGAGENTCVF"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'หน่วยนับยา
    Private Sub ButtonItem77_Click(sender As Object, e As EventArgs) Handles ButtonItem77.Click
        drugUnit.Execute()
    End Sub

    Private Sub drugUnit_Executed(sender As Object, e As EventArgs) Handles drugUnit.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRUGUNIT Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRUGUNIT()
        doc.Text = "DRUGUNIT"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'ลักษณะการแพ้ยา
    Private Sub ButtonItem69_Click(sender As Object, e As EventArgs) Handles ButtonItem69.Click
        drugAllergySymptom.Execute()
    End Sub

    Private Sub drugAllergySymptom_Executed(sender As Object, e As EventArgs) Handles drugAllergySymptom.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DALSYM Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DALSYM()
        doc.Text = "DRUGALLERGYSYMTOMP"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'ความรุนแรงในการแพ้ยา
    Private Sub ButtonItem70_Click(sender As Object, e As EventArgs) Handles ButtonItem70.Click
        drugAlevel.Execute()
    End Sub

    Private Sub drugAlevel_Executed(sender As Object, e As EventArgs) Handles drugAlevel.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DALLEVEL Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DALLEVEL()
        doc.Text = "DRUGALLERGYLEVEL"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'ผู้ให้ข้อมูลการแพ้ยา
    Private Sub ButtonItem71_Click(sender As Object, e As EventArgs) Handles ButtonItem71.Click
        drugInformant.Execute()
    End Sub

    Private Sub drugInformant_Executed(sender As Object, e As EventArgs) Handles drugInformant.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRUGINFORMANT Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRUGINFORMANT()
        doc.Text = "DRUGINFORMANT"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'วินิจฉัยอาการแพ้
    Private Sub ButtonItem72_Click(sender As Object, e As EventArgs) Handles ButtonItem72.Click
        typedx.Execute()
    End Sub

    Private Sub typedx_Executed(sender As Object, e As EventArgs) Handles typedx.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is TYPEDX Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New TYPEDX()
        doc.Text = "TYPEDX"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'การแจ้งเตือนแพ้ยา
    Private Sub ButtonItem73_Click(sender As Object, e As EventArgs) Handles ButtonItem73.Click
        drugAlert.Execute()
    End Sub

    Private Sub drugAlert_Executed(sender As Object, e As EventArgs) Handles drugAlert.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRUGALERT Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRUGALERT()
        doc.Text = "DRUGALERT"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'ยาที่ออกฤทธิ์ต้านกัน
    Private Sub drgdiBtn_Click(sender As Object, e As EventArgs) Handles drgdiBtn.Click
        drgDi.Execute()
    End Sub

    Private Sub drgDi_Executed(sender As Object, e As EventArgs) Handles drgDi.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DRGDILIST Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DRGDILIST()
        doc.Text = "DRGDILIST"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    Private Sub medicalRecordMaster_Click(sender As Object, e As EventArgs) Handles medicalRecordMaster.Click
        medicalRecord.Execute()
        'Dim NewMDIChild As New masPatientInformation
        'Try
        '    For Each f As masPatientInformation In Me.MdiChildren
        '        If (TypeOf (f) Is masPatientInformation) Then
        '            NewMDIChild = f
        '            NewMDIChild.Activate()
        '            Exit Sub
        '        Else
        '            For Each _Form As Form In Me.MdiChildren
        '                _Form.Close()
        '            Next
        '        End If
        '    Next
        'Catch ex As Exception
        '    For Each _Form As Form In Me.MdiChildren
        '        _Form.Close()
        '    Next
        'End Try

        'If (NewMDIChild Is Nothing) Then
        '    NewMDIChild = New masPatientInformation
        'End If
        'NewMDIChild.MdiParent = Me
        'NewMDIChild.Show()
        'NewMDIChild.Dock = DockStyle.Fill
    End Sub

    Private Sub medicalRecord_Executed(sender As Object, e As EventArgs) Handles medicalRecord.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is masMedicalRecord Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New masMedicalRecord()
        doc.Text = "masMedicalRecord"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    Private Sub drugmaster_Click(sender As Object, e As EventArgs) Handles drugmaster.Click
        Dim NewMDIChild As New drugMaster
        Try
            For Each f As drugMaster In Me.MdiChildren
                If (TypeOf (f) Is drugMaster) Then
                    NewMDIChild = f
                    NewMDIChild.Activate()
                    Exit Sub
                Else
                    For Each _Form As Form In Me.MdiChildren
                        _Form.Close()
                    Next
                End If
            Next
        Catch ex As Exception
            For Each _Form As Form In Me.MdiChildren
                _Form.Close()
            Next
        End Try

        If (NewMDIChild Is Nothing) Then
            NewMDIChild = New drugMaster
        End If
        NewMDIChild.MdiParent = Me
        NewMDIChild.Show()
        NewMDIChild.Dock = DockStyle.Fill
    End Sub

    Private Sub ButtonItem1_Click(sender As Object, e As EventArgs) Handles ButtonItem1.Click
        Dim NewMDIChild As New labMaster
        Try
            For Each f As labMaster In Me.MdiChildren
                If (TypeOf (f) Is labMaster) Then
                    NewMDIChild = f
                    NewMDIChild.Activate()
                    Exit Sub
                Else
                    For Each _Form As Form In Me.MdiChildren
                        _Form.Close()
                    Next
                End If
            Next
        Catch ex As Exception
            For Each _Form As Form In Me.MdiChildren
                _Form.Close()
            Next
        End Try

        If (NewMDIChild Is Nothing) Then
            NewMDIChild = New labMaster
        End If
        NewMDIChild.MdiParent = Me
        NewMDIChild.Show()
        NewMDIChild.Dock = DockStyle.Fill
    End Sub

    Private Sub ButtonItem2_Click(sender As Object, e As EventArgs) Handles ButtonItem2.Click
        Dim NewMDIChild As New xray
        Try
            For Each f As xray In Me.MdiChildren
                If (TypeOf (f) Is xray) Then
                    NewMDIChild = f
                    NewMDIChild.Activate()
                    Exit Sub
                Else
                    For Each _Form As Form In Me.MdiChildren
                        _Form.Close()
                    Next
                End If
            Next
        Catch ex As Exception
            For Each _Form As Form In Me.MdiChildren
                _Form.Close()
            Next
        End Try

        If (NewMDIChild Is Nothing) Then
            NewMDIChild = New xray
        End If
        NewMDIChild.MdiParent = Me
        NewMDIChild.Show()
        NewMDIChild.Dock = DockStyle.Fill
    End Sub

    Private Sub ButtonItem4_Click(sender As Object, e As EventArgs) Handles ButtonItem4.Click
        Dim NewMDIChild As New OPERAT
        Try
            For Each f As OPERAT In Me.MdiChildren
                If (TypeOf (f) Is OPERAT) Then
                    NewMDIChild = f
                    NewMDIChild.Activate()
                    Exit Sub
                Else
                    For Each _Form As Form In Me.MdiChildren
                        _Form.Close()
                    Next
                End If
            Next
        Catch ex As Exception
            For Each _Form As Form In Me.MdiChildren
                _Form.Close()
            Next
        End Try

        If (NewMDIChild Is Nothing) Then
            NewMDIChild = New OPERAT
        End If
        NewMDIChild.MdiParent = Me
        NewMDIChild.Show()
        NewMDIChild.Dock = DockStyle.Fill
    End Sub

    Private Sub ButtonItem5_Click(sender As Object, e As EventArgs)
        Dim NewMDIChild As New IMPORTEXCEL
        NewMDIChild.ShowDialog()
        'Try
        '    For Each f As IMPORTEXCEL In Me.MdiChildren
        '        If (TypeOf (f) Is IMPORTEXCEL) Then
        '            NewMDIChild = f
        '            NewMDIChild.Activate()
        '            Exit Sub
        '        Else
        '            For Each _Form As Form In Me.MdiChildren
        '                _Form.Close()
        '            Next
        '        End If
        '    Next
        'Catch ex As Exception
        '    For Each _Form As Form In Me.MdiChildren
        '        _Form.Close()
        '    Next
        'End Try

        'If (NewMDIChild Is Nothing) Then
        '    NewMDIChild = New IMPORTEXCEL
        'End If
        'NewMDIChild.MdiParent = Me
        'NewMDIChild.Show()
        'NewMDIChild.Dock = DockStyle.Fill
    End Sub

    Private Sub ButtonItem6_Click(sender As Object, e As EventArgs) Handles ButtonItem6.Click
        Dim NewMDIChild As New promotionManage
        Try
            For Each f As promotionManage In Me.MdiChildren
                If (TypeOf (f) Is promotionManage) Then
                    NewMDIChild = f
                    NewMDIChild.Activate()
                    Exit Sub
                Else
                    For Each _Form As Form In Me.MdiChildren
                        _Form.Close()
                    Next
                End If
            Next
        Catch ex As Exception
            For Each _Form As Form In Me.MdiChildren
                _Form.Close()
            Next
        End Try

        If (NewMDIChild Is Nothing) Then
            NewMDIChild = New promotionManage
        End If
        NewMDIChild.MdiParent = Me
        NewMDIChild.Show()
        NewMDIChild.Dock = DockStyle.Fill
    End Sub

    Private Sub ButtonItem5_Click_1(sender As Object, e As EventArgs) Handles ButtonItem5.Click
        Dim NewMDIChild As New VSTYPE
        Try
            For Each f As VSTYPE In Me.MdiChildren
                If (TypeOf (f) Is VSTYPE) Then
                    NewMDIChild = f
                    NewMDIChild.Activate()
                    Exit Sub
                Else
                    For Each _Form As Form In Me.MdiChildren
                        _Form.Close()
                    Next
                End If
            Next
        Catch ex As Exception
            For Each _Form As Form In Me.MdiChildren
                _Form.Close()
            Next
        End Try

        If (NewMDIChild Is Nothing) Then
            NewMDIChild = New VSTYPE
        End If
        NewMDIChild.MdiParent = Me
        NewMDIChild.Show()
        NewMDIChild.Dock = DockStyle.Fill
    End Sub

    Private Sub ButtonItem7_Click(sender As Object, e As EventArgs) Handles ButtonItem7.Click
        Dim NewMDIChild As New PROVIDER
        Try
            For Each f As PROVIDER In Me.MdiChildren
                If (TypeOf (f) Is PROVIDER) Then
                    NewMDIChild = f
                    NewMDIChild.Activate()
                    Exit Sub
                Else
                    For Each _Form As Form In Me.MdiChildren
                        _Form.Close()
                    Next
                End If
            Next
        Catch ex As Exception
            For Each _Form As Form In Me.MdiChildren
                _Form.Close()
            Next
        End Try

        If (NewMDIChild Is Nothing) Then
            NewMDIChild = New PROVIDER
        End If
        NewMDIChild.MdiParent = Me
        NewMDIChild.Show()
        NewMDIChild.Dock = DockStyle.Fill
    End Sub

   

    Private Sub ButtonItem8_Click(sender As Object, e As EventArgs) Handles ButtonItem8.Click
        Dim NewMDIChild As New CLINIC
        Try
            For Each f As CLINIC In Me.MdiChildren
                If (TypeOf (f) Is CLINIC) Then
                    NewMDIChild = f
                    NewMDIChild.Activate()
                    Exit Sub
                Else
                    For Each _Form As Form In Me.MdiChildren
                        _Form.Close()
                    Next
                End If
            Next
        Catch ex As Exception
            For Each _Form As Form In Me.MdiChildren
                _Form.Close()
            Next
        End Try

        If (NewMDIChild Is Nothing) Then
            NewMDIChild = New CLINIC
        End If
        NewMDIChild.MdiParent = Me
        NewMDIChild.Show()
        NewMDIChild.Dock = DockStyle.Fill
    End Sub

    Private Sub ButtonItem9_Click(sender As Object, e As EventArgs) Handles ButtonItem9.Click
        Dim NewMDIChild As New rightPrice
        Try
            For Each f As rightPrice In Me.MdiChildren
                If (TypeOf (f) Is rightPrice) Then
                    NewMDIChild = f
                    NewMDIChild.Activate()
                    Exit Sub
                Else
                    For Each _Form As Form In Me.MdiChildren
                        _Form.Close()
                    Next
                End If
            Next
        Catch ex As Exception
            For Each _Form As Form In Me.MdiChildren
                _Form.Close()
            Next
        End Try

        If (NewMDIChild Is Nothing) Then
            NewMDIChild = New rightPrice
        End If
        NewMDIChild.MdiParent = Me
        NewMDIChild.Show()
        NewMDIChild.Dock = DockStyle.Fill
    End Sub

    Private Sub ButtonItem11_Click(sender As Object, e As EventArgs) Handles ButtonItem11.Click
        CMDHOSPITAL.Execute()
    End Sub

    Private Sub CMDHOSPITAL_Executed(sender As Object, e As EventArgs) Handles CMDHOSPITAL.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is HOSPITAL Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New HOSPITAL()
        doc.Text = "HOSPITAL"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    Private Sub ButtonItem12_Click(sender As Object, e As EventArgs)
        Dim NewMDIChild As New CHCODE
        Try
            For Each f As CHCODE In Me.MdiChildren
                If (TypeOf (f) Is CHCODE) Then
                    NewMDIChild = f
                    NewMDIChild.Activate()
                    Exit Sub
                Else
                    For Each _Form As Form In Me.MdiChildren
                        _Form.Close()
                    Next
                End If
            Next
        Catch ex As Exception
            For Each _Form As Form In Me.MdiChildren
                _Form.Close()
            Next
        End Try

        If (NewMDIChild Is Nothing) Then
            NewMDIChild = New CHCODE
        End If
        NewMDIChild.MdiParent = Me
        NewMDIChild.Show()
        NewMDIChild.Dock = DockStyle.Fill
    End Sub

    Private Sub ButtonItem13_Click(sender As Object, e As EventArgs)
        Dim NewMDIChild As New BILLING
        Try
            For Each f As BILLING In Me.MdiChildren
                If (TypeOf (f) Is BILLING) Then
                    NewMDIChild = f
                    NewMDIChild.Activate()
                    Exit Sub
                Else
                    For Each _Form As Form In Me.MdiChildren
                        _Form.Close()
                    Next
                End If
            Next
        Catch ex As Exception
            For Each _Form As Form In Me.MdiChildren
                _Form.Close()
            Next
        End Try

        If (NewMDIChild Is Nothing) Then
            NewMDIChild = New BILLING
        End If
        NewMDIChild.MdiParent = Me
        NewMDIChild.Show()
        NewMDIChild.Dock = DockStyle.Fill
    End Sub

    Private Sub ButtonItem14_Click(sender As Object, e As EventArgs)
        Dim NewMDIChild As New TEMPBILLING
        Try
            For Each f As TEMPBILLING In Me.MdiChildren
                If (TypeOf (f) Is TEMPBILLING) Then
                    NewMDIChild = f
                    NewMDIChild.Activate()
                    Exit Sub
                Else
                    For Each _Form As Form In Me.MdiChildren
                        _Form.Close()
                    Next
                End If
            Next
        Catch ex As Exception
            For Each _Form As Form In Me.MdiChildren
                _Form.Close()
            Next
        End Try

        If (NewMDIChild Is Nothing) Then
            NewMDIChild = New TEMPBILLING
        End If
        NewMDIChild.MdiParent = Me
        NewMDIChild.Show()
        NewMDIChild.Dock = DockStyle.Fill
    End Sub

    Private Sub ButtonItem15_Click(sender As Object, e As EventArgs)
        Dim NewMDIChild As New RGTONBILL
        Try
            For Each f As RGTONBILL In Me.MdiChildren
                If (TypeOf (f) Is RGTONBILL) Then
                    NewMDIChild = f
                    NewMDIChild.Activate()
                    Exit Sub
                Else
                    For Each _Form As Form In Me.MdiChildren
                        _Form.Close()
                    Next
                End If
            Next
        Catch ex As Exception
            For Each _Form As Form In Me.MdiChildren
                _Form.Close()
            Next
        End Try

        If (NewMDIChild Is Nothing) Then
            NewMDIChild = New RGTONBILL
        End If
        NewMDIChild.MdiParent = Me
        NewMDIChild.Show()
        NewMDIChild.Dock = DockStyle.Fill
    End Sub

    Private Sub ButtonItem16_Click(sender As Object, e As EventArgs)
        Dim NewMDIChild As New CMSPHERE
        Try
            For Each f As CMSPHERE In Me.MdiChildren
                If (TypeOf (f) Is CMSPHERE) Then
                    NewMDIChild = f
                    NewMDIChild.Activate()
                    Exit Sub
                Else
                    For Each _Form As Form In Me.MdiChildren
                        _Form.Close()
                    Next
                End If
            Next
        Catch ex As Exception
            For Each _Form As Form In Me.MdiChildren
                _Form.Close()
            Next
        End Try

        If (NewMDIChild Is Nothing) Then
            NewMDIChild = New CMSPHERE
        End If
        NewMDIChild.MdiParent = Me
        NewMDIChild.Show()
        NewMDIChild.Dock = DockStyle.Fill
    End Sub

    Private Sub ButtonItem12_Click_1(sender As Object, e As EventArgs)
        Dim NewMDIChild As New CHCODE
        Try
            For Each f As CHCODE In Me.MdiChildren
                If (TypeOf (f) Is CHCODE) Then
                    NewMDIChild = f
                    NewMDIChild.Activate()
                    Exit Sub
                Else
                    For Each _Form As Form In Me.MdiChildren
                        _Form.Close()
                    Next
                End If
            Next
        Catch ex As Exception
            For Each _Form As Form In Me.MdiChildren
                _Form.Close()
            Next
        End Try

        If (NewMDIChild Is Nothing) Then
            NewMDIChild = New CHCODE
        End If
        NewMDIChild.MdiParent = Me
        NewMDIChild.Show()
        NewMDIChild.Dock = DockStyle.Fill
    End Sub

    Private Sub ButtonItem13_Click_1(sender As Object, e As EventArgs)
        Dim NewMDIChild As New TEMPBILLING
        Try
            For Each f As TEMPBILLING In Me.MdiChildren
                If (TypeOf (f) Is TEMPBILLING) Then
                    NewMDIChild = f
                    NewMDIChild.Activate()
                    Exit Sub
                Else
                    For Each _Form As Form In Me.MdiChildren
                        _Form.Close()
                    Next
                End If
            Next
        Catch ex As Exception
            For Each _Form As Form In Me.MdiChildren
                _Form.Close()
            Next
        End Try

        If (NewMDIChild Is Nothing) Then
            NewMDIChild = New TEMPBILLING
        End If
        NewMDIChild.MdiParent = Me
        NewMDIChild.Show()
        NewMDIChild.Dock = DockStyle.Fill
    End Sub

    Private Sub ButtonItem14_Click_1(sender As Object, e As EventArgs)
        Dim NewMDIChild As New RGTONBILL
        Try
            For Each f As RGTONBILL In Me.MdiChildren
                If (TypeOf (f) Is RGTONBILL) Then
                    NewMDIChild = f
                    NewMDIChild.Activate()
                    Exit Sub
                Else
                    For Each _Form As Form In Me.MdiChildren
                        _Form.Close()
                    Next
                End If
            Next
        Catch ex As Exception
            For Each _Form As Form In Me.MdiChildren
                _Form.Close()
            Next
        End Try

        If (NewMDIChild Is Nothing) Then
            NewMDIChild = New RGTONBILL
        End If
        NewMDIChild.MdiParent = Me
        NewMDIChild.Show()
        NewMDIChild.Dock = DockStyle.Fill
    End Sub

    Private Sub ButtonItem15_Click_1(sender As Object, e As EventArgs)
        Dim NewMDIChild As New CMSPHERE
        Try
            For Each f As CMSPHERE In Me.MdiChildren
                If (TypeOf (f) Is CMSPHERE) Then
                    NewMDIChild = f
                    NewMDIChild.Activate()
                    Exit Sub
                Else
                    For Each _Form As Form In Me.MdiChildren
                        _Form.Close()
                    Next
                End If
            Next
        Catch ex As Exception
            For Each _Form As Form In Me.MdiChildren
                _Form.Close()
            Next
        End Try

        If (NewMDIChild Is Nothing) Then
            NewMDIChild = New CMSPHERE
        End If
        NewMDIChild.MdiParent = Me
        NewMDIChild.Show()
        NewMDIChild.Dock = DockStyle.Fill
    End Sub

    Private Sub ButtonItem16_Click_1(sender As Object, e As EventArgs)
        Dim NewMDIChild As New BILLING
        Try
            For Each f As BILLING In Me.MdiChildren
                If (TypeOf (f) Is BILLING) Then
                    NewMDIChild = f
                    NewMDIChild.Activate()
                    Exit Sub
                Else
                    For Each _Form As Form In Me.MdiChildren
                        _Form.Close()
                    Next
                End If
            Next
        Catch ex As Exception
            For Each _Form As Form In Me.MdiChildren
                _Form.Close()
            Next
        End Try

        If (NewMDIChild Is Nothing) Then
            NewMDIChild = New BILLING
        End If
        NewMDIChild.MdiParent = Me
        NewMDIChild.Show()
        NewMDIChild.Dock = DockStyle.Fill
    End Sub



    Private Sub ButtonItem28_Click(sender As Object, e As EventArgs)
        CMDDIAG.Execute()
    End Sub

    Private Sub CMDDIAG_Executed(sender As Object, e As EventArgs) Handles CMDDIAG.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DIAG Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DIAG()
        doc.Text = "รหัสโรค ICD"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    Private Sub RibbonControl1_Click(sender As Object, e As EventArgs) Handles RibbonControl1.Click

    End Sub

    Private Sub CMDmasPatientInformation_Executed(sender As Object, e As EventArgs) Handles CMDmasPatientInformation.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is masPatientInformation Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New masPatientInformation()
        doc.Text = "เวชระเบียน"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub



    Private Sub drugmaster_Click_1(sender As Object, e As EventArgs) Handles drugmaster.Click

    End Sub

    Private Sub ButtonItem57_Click(sender As Object, e As EventArgs) Handles ButtonItem57.Click

    End Sub

    Private Sub ButtonItem34_Click(sender As Object, e As EventArgs)

    End Sub

    'stock
    Private Sub btnStock_click(sender As Object, e As EventArgs) Handles btnStock.Click
        stock.Execute()
    End Sub

    Private Sub stock_Executed(sender As Object, e As EventArgs) Handles stock.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is STOCK Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New STOCK()
        doc.Text = "STOCK"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'sroomitem ห้องพัก เตียง
    Private Sub btnSroomitem_Click(sender As Object, e As EventArgs) Handles btnSroomitem.Click
        sRoomItem.Execute()
    End Sub

    Private Sub sRoomItem_Executed(sender As Object, e As EventArgs) Handles sRoomItem.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is SROOMITEM Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New SROOMITEM()
        doc.Text = "SROOMITEM"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'อาหาร
    Private Sub btnMasterFood_Click(sender As Object, e As EventArgs) Handles btnMasterFood.Click
        fdItem.Execute()
    End Sub

    Private Sub fdItem_Executed(sender As Object, e As EventArgs) Handles fdItem.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is FDITEM Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New FDITEM()
        doc.Text = "FDITEM"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub


    'ตั้งราคามาตรฐานรายตัว
    Private Sub ButtonItem111_Click(sender As Object, e As EventArgs) Handles ButtonItem111.Click
        defaultPriceSingle.Execute()
    End Sub

    Private Sub defaultPriceSingle_Executed(sender As Object, e As EventArgs) Handles defaultPriceSingle.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DPRICESINGLE Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DPRICESINGLE()
        doc.Text = "DEFAULTPRICESINGLE"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'ตั้งราคามาตรฐานรายกลุ่ม
    Private Sub ButtonItem112_Click(sender As Object, e As EventArgs) Handles ButtonItem112.Click
        defaultPricePackage.Execute()
    End Sub

    Private Sub defaultPricePackage_Executed(sender As Object, e As EventArgs) Handles defaultPricePackage.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is DPRICEPACK Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New DPRICEPACK()
        doc.Text = "DEFAULTPRICEPACKAGE"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'ราคาคู่สัญญารายกลุ่ม
    Private Sub ButtonItem114_Click(sender As Object, e As EventArgs) Handles ButtonItem114.Click
        rightPricePackage.Execute()
    End Sub

    Private Sub rightPricePackage_Executed(sender As Object, e As EventArgs) Handles rightPricePackage.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is RPRICEPACK Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New RPRICEPACK()
        doc.Text = "RIGHTPRICEPACKAGE"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'ราคาคู่สัญญารายตัว
    Private Sub ButtonItem113_Click(sender As Object, e As EventArgs) Handles ButtonItem113.Click
        rightPriceSingle.Execute()
    End Sub

    Private Sub rightPriceSingle_Executed(sender As Object, e As EventArgs) Handles rightPriceSingle.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is RPRICESIN Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New RPRICESIN()
        doc.Text = "RIGHTPRICESINGLE"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'สูตรราคา
    Private Sub ButtonItem109_Click(sender As Object, e As EventArgs) Handles ButtonItem109.Click
        priceFormula.Execute()
    End Sub

    Private Sub priceFormula_Executed(sender As Object, e As EventArgs) Handles priceFormula.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is PRICEFORMULA Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New PRICEFORMULA()
        doc.Text = "PRICEFORMULA"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'หมวดผลิตภัณฑ์
    Private Sub ButtonItem110_Click(sender As Object, e As EventArgs) Handles ButtonItem110.Click
        productCategorie.Execute()
    End Sub

    Private Sub productCategorie_Executed(sender As Object, e As EventArgs) Handles productCategorie.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is PRODUCTCAT Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New PRODUCTCAT()
        doc.Text = "PRODUCTCAT"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'รายการหัตถการ
    Private Sub ButtonItem98_Click(sender As Object, e As EventArgs) Handles ButtonItem98.Click
        operateItem.Execute()
    End Sub

    Private Sub operateItem_Executed(sender As Object, e As EventArgs) Handles operateItem.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is OPERATEITEM Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New OPERATEITEM()
        doc.Text = "OPERATEITEM"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'กลุ่มหัตถการ
    Private Sub ButtonItem99_Click(sender As Object, e As EventArgs) Handles ButtonItem99.Click
        operateGroup.Execute()
    End Sub

    Private Sub operateGroup_Executed(sender As Object, e As EventArgs) Handles operateGroup.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is OPERATEGROUP Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New OPERATEGROUP()
        doc.Text = "OPERATEGROUP"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'template หัตถการ
    Private Sub ButtonItem100_Click(sender As Object, e As EventArgs) Handles ButtonItem100.Click
        operateTemplate.Execute()
    End Sub

    Private Sub operateTemplate_Executed(sender As Object, e As EventArgs) Handles operateTemplate.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is OPERATETEMPLATE Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New OPERATETEMPLATE()
        doc.Text = "OPERATETEMPLATE"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'XrayItem
    Private Sub ButtonItem91_Click(sender As Object, e As EventArgs) Handles ButtonItem91.Click
        XrayItem.Execute()
    End Sub

    Private Sub XrayItem_Executed(sender As Object, e As EventArgs) Handles XrayItem.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is XRAYITEMLIST Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New XRAYITEMLIST()
        doc.Text = "XRAYITEMLIST"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    Private Sub ButtonItem92_Click(sender As Object, e As EventArgs) Handles ButtonItem92.Click
        XrayPart.Execute()
    End Sub

    Private Sub XrayPart_Executed(sender As Object, e As EventArgs) Handles XrayPart.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is XRAYPART Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New XRAYPART()
        doc.Text = "XRAYPART"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    Private Sub ButtonItem93_Click(sender As Object, e As EventArgs) Handles ButtonItem93.Click
        XrayPos.Execute()
    End Sub

    Private Sub XrayPos_Executed(sender As Object, e As EventArgs) Handles XrayPos.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is XRAYPOS Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New XRAYPOS()
        doc.Text = "XRAYPOS"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    Private Sub ButtonItem94_Click(sender As Object, e As EventArgs) Handles ButtonItem94.Click
        XrayCLS.Execute()
    End Sub

    Private Sub XrayCLS_Executed(sender As Object, e As EventArgs) Handles XrayCLS.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is XRAYCLS Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New XRAYCLS()
        doc.Text = "XRAYCLS"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'รายการโปรโมชั่น
    Private Sub ButtonItem120_Click(sender As Object, e As EventArgs) Handles ButtonItem120.Click
        promotionList.Execute()
    End Sub

    Private Sub promotionList_Executed(sender As Object, e As EventArgs) Handles promotionList.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is PROMOTIONLIST Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New PROMOTIONLIST()
        doc.Text = "PROMOTIONLIST"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'สินค้าในโปรโมชั่น
    Private Sub ButtonItem121_Click(sender As Object, e As EventArgs) Handles ButtonItem121.Click
        productInPromotion.Execute()
    End Sub

    Private Sub productInPromotion_Executed(sender As Object, e As EventArgs) Handles productInPromotion.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is PRODINPROM Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New PRODINPROM()
        doc.Text = "PRODUCTINPROMOTION"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'test
    Private Sub ButtonItem116_Click(sender As Object, e As EventArgs) Handles ButtonItem116.Click
        test.Execute()
    End Sub

    Private Sub test_Executed(sender As Object, e As EventArgs) Handles test.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is test Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New test()
        doc.Text = "test"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'กลุ่ม lab
    Private Sub ButtonItem95_Click(sender As Object, e As EventArgs) Handles ButtonItem95.Click
        labOrder.Execute()
    End Sub

    Private Sub labOrder_Executed(sender As Object, e As EventArgs) Handles labOrder.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is LABORDER Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New LABORDER()
        doc.Text = "LABORDER"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'รายการตรวจ
    Private Sub ButtonItem96_Click(sender As Object, e As EventArgs) Handles ButtonItem96.Click
        labGroup.Execute()
    End Sub

    Private Sub labGroup_Executed(sender As Object, e As EventArgs) Handles labGroup.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is LABGROUP Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New LABGROUP()
        doc.Text = "LABGROUP"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'รายการส่งตรวจ
    Private Sub ButtonItem97_Click(sender As Object, e As EventArgs) Handles ButtonItem97.Click
        labItem.Execute()
    End Sub

    Private Sub labItem_Executed(sender As Object, e As EventArgs) Handles labItem.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is LABITEM Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New LABITEM()
        doc.Text = "LABITEM"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub



    'รูปแบบใบเสร็จ
    Private Sub ButtonItem82_Click(sender As Object, e As EventArgs) Handles ButtonItem82.Click
        receiptType.Execute()
    End Sub

    Private Sub receiptType_Executed(sender As Object, e As EventArgs) Handles receiptType.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is RECEIPTTYPE Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New RECEIPTTYPE()
        doc.Text = "RECEIPTTYPE"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'รหัสรายการและรหัสรายได้
    Private Sub ButtonItem83_Click(sender As Object, e As EventArgs) Handles ButtonItem83.Click
        revenueID.Execute()
    End Sub

    Private Sub revenueID_Executed(sender As Object, e As EventArgs) Handles revenueID.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is REVENUEID Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New REVENUEID()
        doc.Text = "REVENUEID"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'รายการในใบเสร็จ

    Private Sub ButtonItem84_Click(sender As Object, e As EventArgs) Handles ButtonItem84.Click
        listInReceipt.Execute()
    End Sub

    Private Sub listInReceipt_Executed(sender As Object, e As EventArgs) Handles listInReceipt.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is LISTINRECEIPT Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New LISTINRECEIPT()
        doc.Text = "LISTINRECEIPT"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'คู่สัญญากับใบเสร็จ
    Private Sub ButtonItem85_Click(sender As Object, e As EventArgs) Handles ButtonItem85.Click
        rightAndReceipt.Execute()
    End Sub

    Private Sub rightAndReceipt_Executed(sender As Object, e As EventArgs) Handles rightAndReceipt.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is RIGHTANDRECEIPT Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New RIGHTANDRECEIPT()
        doc.Text = "RIGHTANDRECEIPT"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'รหัสรายการกับสินค้า
    Private Sub ButtonItem86_Click(sender As Object, e As EventArgs) Handles ButtonItem86.Click
        listAndProduct.Execute()
    End Sub

    Private Sub listAndProduct_Executed(sender As Object, e As EventArgs) Handles listAndProduct.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is LISTIDANDPRODUCT Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New LISTIDANDPRODUCT()
        doc.Text = "LISTANDPRODUCT"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'แม่แบบใบเสร็จ
    Private Sub ButtonItem117_Click(sender As Object, e As EventArgs) Handles ButtonItem117.Click
        templateBill.Execute()
    End Sub

    Private Sub templateBill_Executed(sender As Object, e As EventArgs) Handles templateBill.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is TEMPLATEBILLING Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New TEMPLATEBILLING()
        doc.Text = "TEMPLATEBILLING"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'การรับเงิน
    Private Sub btnMasacceptm_Click(sender As Object, e As EventArgs) Handles btnMasacceptm.Click
        masacceptm.Execute()
    End Sub

    Private Sub masacceptm_Executed(sender As Object, e As EventArgs) Handles masacceptm.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is MASACCEPTM Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New MASACCEPTM()
        doc.Text = "MASACCEPTM"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'กำหนดคอมพิวเตอร์
    Private Sub ButtonItem87_Click(sender As Object, e As EventArgs) Handles ButtonItem87.Click
        CMSPHERE.Execute()
    End Sub

    Private Sub CMSPHERE_Executed(sender As Object, e As EventArgs) Handles CMSPHERE.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is CMSPHERE Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New CMSPHERE()
        doc.Text = "CMSPHERE"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'กำหนด printer
    Private Sub ButtonItem138_Click(sender As Object, e As EventArgs) Handles ButtonItem138.Click
        PRINTER.Execute()
    End Sub

    Private Sub PRINTER_Executed(sender As Object, e As EventArgs) Handles PRINTER.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is PRINTER Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New PRINTER()
        doc.Text = "PRINTER"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    'จัดการผู้ใช้
    Private Sub ButtonItem139_Click(sender As Object, e As EventArgs) Handles ButtonItem139.Click
        userAccount.Execute()
    End Sub

    Private Sub userAccount_Executed(sender As Object, e As EventArgs) Handles userAccount.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is MAINUSERPRG Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New MAINUSERPRG()
        doc.Text = "USERACCOUNT"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    Private Sub ButtonItem28_Click_1(sender As Object, e As EventArgs) Handles ButtonItem28.Click
        agentOfDrugmaker.Execute()
    End Sub

    Private Sub agentOfDrugmaker_Executed(sender As Object, e As EventArgs) Handles agentOfDrugmaker.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is AGENTOFMAKER Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New AGENTOFMAKER()
        doc.Text = "DRUGAGENTOFDRUGMAKER"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    Private Sub ButtonItem119_Click(sender As Object, e As EventArgs) Handles ButtonItem119.Click
        vaccineDuration.Execute()
    End Sub

    Private Sub vaccineDuration_Executed(sender As Object, e As EventArgs) Handles vaccineDuration.Executed
        For Each f As Form In Application.OpenForms
            If TypeOf f Is VACCINEDURATION Then
                f.Activate()
                Exit Sub
            Else

            End If
        Next
        Dim doc As New VACCINEDURATION()
        doc.Text = "VACCINEDURATION"
        doc.MdiParent = Me
        doc.WindowState = FormWindowState.Maximized
        doc.Show()
        doc.Update()
    End Sub

    Private Sub main_Load(sender As Object, e As EventArgs) Handles Me.Load

        DesignForm(Me)
    End Sub


    Private Sub txtUserRequest_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtUserRequest.KeyPress
        If e.KeyChar = Convert.ToChar(13) Then
            If txtUserRequest.Text.Trim <> "" Then
                PROVIDERPOLICIES.GETHOSEM(CStr(txtUserRequest.Text.Trim), Convert.ToString(Me.Tag))
                If PROVIDERPOLICIES._CHECKUSRFAIL = False Then
                    SETUIUSERREQ()

                    medicalRecordRibbonPanel.Enabled = true
                    hospitalRibbonPanel.Enabled = True
                    productAndServiceRibbonPanel.Enabled = True
                    supportRibbonPanel.Enabled = True
                    administratorRibbonPanel.Enabled = True
                    friendRibbonPanel.Enabled = True
                Else
                    SETUIUSERREQ()
                    txtUserRequest.Text = ""
                    MsgBox(PROVIDERPOLICIES._CHECKUSRFAILMSG)
                End If
            End If
        End If
    End Sub
    Public Sub SETUIUSERREQ()
        txtUsername.Text = PROVIDERPOLICIES.txtusername_
        txtUsername.Tag = PROVIDERPOLICIES.txtusername_tag_
        btnLogout.Visible = PROVIDERPOLICIES.btnlogout_
    End Sub
    Private Sub btnLogout_Click(sender As Object, e As EventArgs) Handles btnLogout.Click
        PROVIDERPOLICIES.LOGOUT(Convert.ToString(Me.Tag))
        SETUIUSERREQ()
        txtUserRequest.Text = ""

        medicalRecordRibbonPanel.Enabled = False
        hospitalRibbonPanel.Enabled = False
        productAndServiceRibbonPanel.Enabled = False
        supportRibbonPanel.Enabled = False
        administratorRibbonPanel.Enabled = False
        friendRibbonPanel.Enabled = False
    End Sub
End Class
